extends Label
class_name HealthAnim

var health_size : int
func _ready() -> void:
	hide()
	visibility_changed.connect(_on_visibility_changed)

func _on_visibility_changed() -> void :
	if not visible : return
	if health_size == 0 : return
	text = str(health_size)
	var tween = create_tween()
	tween.tween_property(self, "position", Vector2(-50.0,-60.0), 0.2).set_trans(Tween.TRANS_BOUNCE)
	tween.tween_callback(
		func() :
			await get_tree().create_timer(0.2).timeout
			hide()
			position = Vector2(-50.0,0.0)
	)
